package com.youxue.teachin.user.newuser.usercase;

import com.library.rest.ApiServiceManager;
import com.library.rest.rxjava.RxResultHelper;
import com.library.rest.rxjava.RxSchedulersHelper;
import com.youxue.teachin.common.vo.UserVO;
import com.youxue.teachin.user.repository.IUserRepository;
import rx.Observable;

/**
 * 在此写用途
 *
 * @author: zhiwei
 * @date: 2017-10-05 10:37
 * @version: 9.1.0
 */
public class NewUserUsercase {
    IUserRepository mUserRepository;
    public NewUserUsercase() {
        Class<IUserRepository> clazz = IUserRepository.class;
        mUserRepository = ApiServiceManager.getOrCreateApiService(clazz);
    }
    public Observable<String> getCaptcha(String phone, String type){
        return mUserRepository.getCaptcha(phone, type)
            .compose(RxResultHelper.<String>handleResult())
            .compose(RxSchedulersHelper.<String>io_main());

    }

    public Observable<UserVO> createNewUser(String phone, String password, String authcoe) {
        return mUserRepository.createNewUser(phone, password, authcoe, "1")
            .compose(RxResultHelper.<UserVO>handleResult())
            .compose(RxSchedulersHelper.<UserVO>io_main());
    }

}
